package com.gaojiabao.panghu.config;

import com.gaojiabao.panghu.interceptor.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author gaojiabao
 * @date 10:01 2024/11/4
 * @description WebMvcConfig配置类
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //拦截所有路径
                .addPathPatterns("/**")
                //排除登录路径
                .excludePathPatterns("/login","/login/**")
                //排除knife4j
                .excludePathPatterns("/doc.html", "/webjars/**", "/v3/api-docs/**", "/swagger-ui.html");
    }
}